#ifndef SROS_DEVICE_SUPPORT_PTOTO_HPP
#define SROS_DEVICE_SUPPORT_PTOTO_HPP

#include <nlohmann/json.hpp>

#include <string>
#include <vector>
#include <stdint.h>

struct DriverStatus
{
    uint32_t id;
    int32_t current;
    int32_t temperature;
    int32_t speed;
    int32_t rpm;
    int32_t pos;
    int32_t pulse;
    uint32_t error;
    uint32_t status_word;
    uint8_t state;
    uint32_t mode;
    bool enable;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(DriverStatus, id, current, temperature, speed, rpm, pos, pulse, error, status_word, state, mode, enable)
};

// 往外发布的电机状态数据
struct PubDriverStatus
{
    std::vector<DriverStatus> H;
    DriverStatus V;
    DriverStatus P;
    DriverStatus R;
    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(PubDriverStatus, H, V, P, R)
};

struct DriverInfo
{
    uint32_t id;
    std::string sn;
    std::string hardware_version;
    std::string software_version;
    std::string datetime;
    std::string manufacturer;
    std::string model;
    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(DriverInfo, id, sn, hardware_version, software_version, datetime, manufacturer, model)
};

// 往外发布的电机信息数据
struct PubDriverInfo
{
    std::vector<DriverInfo> H;
    DriverInfo V;
    DriverInfo P;
    DriverInfo R;
    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(PubDriverInfo, H, V, P, R)
};

// 编码器数据信息
struct EncoderStatus
{
    uint32_t id;     // 0水平 1垂直
    int32_t  pulse;  // 编码器脉冲累计值
    int32_t  pos;    // 编码器转换后的位置数值 mm

    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(EncoderStatus, id, pulse, pos)
};

// 往外发布的电机相关的事件
struct PubDriverEvent
{
    uint8_t ev_id;
    uint8_t dir;            // driver dir
    uint32_t ev_data;       // driver id
    std::string ev_msg;

    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(PubDriverEvent, ev_id, dir, ev_data, ev_msg)
};

// 往外发布的RFID相关事件
struct PubRfidEvent
{
    uint8_t ev_id;
    uint32_t ev_data;
    std::string ev_msg;
    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(PubRfidEvent, ev_id, ev_data, ev_msg)
};

// 订阅的驱动器控制指令
struct DriverCmd
{
    uint8_t dir;   // 驱动器方向
    uint8_t cmd;   // 指令
    int32_t data;  // 指令数据            
   
    NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_DEFAULT(DriverCmd, dir, cmd, data)
};


#endif